/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.brain.plan.dto;

import com.brain.core.dto.ComunDto;
import com.brain.plan.view.util.ConstantesPlan;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;
import javax.validation.constraints.Size;

/**
 *
 * @author HvivesO
 */
@Entity
@Table(name = "TPLAN_CALCULO")
public class CalculoDto extends ComunDto implements Serializable {

    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "SEQ_TPLAN_CALCULO")
    @TableGenerator(name = "SEQ_TPLAN_CALCULO", table = "TCORE_ENTIDAD", pkColumnName = "NOMBRE", valueColumnName = "CORRELATIVO", pkColumnValue = "TPLAN_CALCULO", allocationSize = 1)
    private Long id;
    @JoinColumn(name = "PERIODO", referencedColumnName = "ID")
    @ManyToOne
    private PeriodoDto periodoDto;
    @Size(max = 100)
    @Column(name = "NUM_BOLETA")
    private String numBoleta;
    @Size(max = 100)
    @Column(name = "FOLIO_PLANILLA")
    private String folioPlanilla;
    @Transient
    private Boolean isPeriodoCerrado;

    public CalculoDto() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public PeriodoDto getPeriodoDto() {
        return periodoDto;
    }

    public void setPeriodoDto(PeriodoDto periodoDto) {
        this.periodoDto = periodoDto;
    }

    public String getNumBoleta() {
        return numBoleta;
    }

    public void setNumBoleta(String numBoleta) {
        this.numBoleta = numBoleta;
    }

    public String getFolioPlanilla() {
        return folioPlanilla;
    }

    public void setFolioPlanilla(String folioPlanilla) {
        this.folioPlanilla = folioPlanilla;
    }

    public Boolean getIsPeriodoCerrado() {
        if (periodoDto != null) {
            if (periodoDto.getEstado().equals(ConstantesPlan.ValoresConstantes.PERIODO_COD_ESTADO_CERRADO)) {
                isPeriodoCerrado = true;
            } else {
                isPeriodoCerrado = false;
            }
        } else {
            isPeriodoCerrado = false;
        }
        return isPeriodoCerrado;
    }

    public void setIsPeriodoCerrado(Boolean isPeriodoCerrado) {
        this.isPeriodoCerrado = isPeriodoCerrado;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CalculoDto)) {
            return false;
        }
        CalculoDto other = (CalculoDto) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.brain.plan.dto.CalculoDto[ id=" + id + " ]";
    }
}
